package com.hq.common.scheduler.initializer;

import com.hq.common.initializer.AbstractInitializer;
import com.hq.common.scheduler.SchedulerManager;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.stereotype.Component;

/**
 * Created by He Zhijie on 2015/7/19.
 */
public class SchedulerInitializer extends AbstractInitializer {

    @Autowired
    @Qualifier("schedulerFactory")
    private SchedulerFactoryBean schedulerFactory;

    @Override
    public void init() throws SchedulerException {
//        SchedulerFactory schedulerFactory= ApplicationContextUtils.getBean("schedulerFactory");
        Scheduler scheduler=schedulerFactory.getScheduler();
        scheduler.start();
        SchedulerManager.addJobs();
    }

    @Override
    public String getDesc() {
        return "任务调度";
    }
}
